import mysql from "mysql"
export default class JXPJ{
    constructor(res) {
        res.writeHead(200, {
            "Content-Type": "application/json;charset=utf-8",
            "Access-Control-Allow-Origin": "*"
        })
        this.result(res)
    }
    result(res) {
        var connection = mysql.createConnection({
            host: 'localhost',
            user: 'root',
            password: 'root',
            port: '3306',
            database: 'test'
        });

        connection.connect();

        var sql = 'SELECT * FROM test.JXPJ';
        connection.query(sql, function (err, result) {
            if (err) {
                console.log('[SELECT ERROR] - ', err.message);
                return;
            }
            return res.end(JSON.stringify(result));
        });

        connection.end();

    }
}
